<template>
	<el-dialog :title="titleMap[mode]" v-model="visible" width="70%" destroy-on-close @closed="$emit('closed')" :close-on-click-modal="false">
        <el-container>
			<el-main class="nopadding">
			    <el-header></el-header>
				<scTable ref="table" :data="data" stripe remoteSort remoteFilter height="460" border>
					<el-table-column width="1" align="center"></el-table-column>
					<el-table-column type="selection" width="50" align="center"></el-table-column>
                    <el-table-column prop="production_code" label="单据编号" align="center"></el-table-column>
                    <el-table-column prop="production_number" label="生产计划数" align="center"></el-table-column>
                    <el-table-column prop="in_number" label="已入库数" align="center"></el-table-column>
                    <el-table-column prop="residue_number" label="剩余可入库数" align="center"></el-table-column>
                    <el-table-column prop="this_ware" label="本次入库数" align="center"></el-table-column>
				</scTable>
			</el-main>
		</el-container>
		<template #footer>
			<el-button @click="visible = false">取 消</el-button>
		</template>
	</el-dialog>
</template>

<script>
export default {
	emits: ['success', 'closed'],
	data() {
		return {
			mode: "add",
			titleMap: {
				add: '选择设备',
				edit: '入库记录',
			},
			visible: false,
			isSaveing: false,
            apiObj: this.$API.device.deviceList.getList,
            selection:[],
            data: []
		}
	},
	mounted() {
	},
	methods: {
		//显示
		open(mode = 'add') {
			this.mode = mode;
			this.visible = true;
			return this
		},
        async setData(data) {
			var reqData = {id: data.id}
			var res = await this.$API.production.inhouse.detail.post(reqData);
            let array = []
            res.data.ware_detail.map(item=>{
                array.push({
                    id:item.id,
                    machin_id:item.machin_id,
                    production_code:item.machin.production_code,
                    production_number:res.data.work_plan.qualified_num,
                    residue_number:res.data.work_plan.qualified_num - item.machin.ware_number,
                    in_number:item.machin.ware_number,
                    this_ware:item.this_ware,
                })
            })
            this.data = array
		},
        selectionChange(selection) {
			if(selection.length > 1){
				const del_row = selection.shift()
				this.$refs.table.toggleRowSelection(del_row,false) //设置这一行取消选中
			}
			this.selection = selection;
		},
	}
}
</script>

<style></style>
